import { createContext } from 'react';
import { InternalFormInstance } from '../interface/index';

const warningFunc: any = (...args: any) => {
  console.warn('--FieldContext function no initial --');
};

export interface FiledContextProps extends InternalFormInstance {
  validateTrigger: string | string[];
}

const FiledContext = createContext<FiledContextProps>({
  getFieldValue: warningFunc,
  getFieldsValue: warningFunc,
  setFieldValue: warningFunc,
  setFieldsValue: warningFunc,
  setFields: warningFunc,
  resetFields: warningFunc,
  validateFields: warningFunc,
  submit: warningFunc,
  validateTrigger: 'onChange',
  getInternalHooks: (scret: string) => ({
    updateValue: warningFunc,
    initEntityValue: warningFunc,
    registerField: warningFunc,
    cancelField: warningFunc,
    setInitialValues: warningFunc,
    destroyForm: warningFunc,
    setCallbacks: warningFunc,
    // registerWatch: (callback: WatchCallBack) => () => void;
    getFields: warningFunc,
    setValidateMessages: warningFunc,
    getInitialValue: warningFunc,
  }),
});

export default FiledContext;
export const HOOK_MARK = 'RC_FORM_INTERNAL_HOOKS';
